﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pata.SylkSharp.Core.Bll
{
    
    /// <summary>
    /// Enumerates the possible fields in a <see cref="PRecord"/>
    /// </summary>
    public enum PRecordFieldType
    {
        /// <summary>
        /// Excel style cell format specification
        /// </summary>
        P,
        /// <summary>
        /// Unknown field type.
        /// </summary>
        Unknown = 100
    }

    /// <summary>
    /// Object representation of field of a Sylk record of type 'P'
    /// </summary>
    public class PRecordField : FieldBase<PRecordFieldType>
    {
        /// <summary>
        /// Instanciate a new <see cref="PRecordField"/>
        /// </summary>
        public PRecordField()
            : base(PRecordFieldType.Unknown, String.Empty) { }

        /// <summary>
        /// Instanciate a new <see cref="PRecordField"/>
        /// </summary>
        /// <param name="pType">Type of this field.</param>
        /// <param name="pValue">The value contained by this field.</param>
        public PRecordField(PRecordFieldType pType, string pValue)
            : base(pType, pValue) { }
    }

    /// <summary>
    /// Object representation of a Sylk record of type 'P'. Cell format. If F records are present, precedes them.
    /// </summary>
    public class PRecord : RecordBase<PRecordField, PRecordFieldType>
    {
        //TODO:Complete this array.
        private static readonly PRecordFieldType[] _MANDATORY_FIELDS = new PRecordFieldType[] { PRecordFieldType.P };

        /// <summary>
        /// Instanciate a new <see cref="PRecord"/>
        /// </summary>
        public PRecord(string pLineWithoutId)
            : base(RecordType.P, pLineWithoutId, PRecordFieldType.Unknown) { }

        /// <summary>
        /// Get mandatory fields for this record.
        /// </summary>
        /// <returns></returns>
        public override System.Collections.Generic.IEnumerable<PRecordFieldType> GetMandatoryFields()
        {
            return _MANDATORY_FIELDS;
        }

        /// <summary>
        /// Get the default field type.
        /// </summary>
        /// <returns></returns>
        public override PRecordFieldType GetUnknownFieldType()
        {
            return PRecordFieldType.Unknown;
        }
    }
}
